package com.yanqu.road.server.cmd.banquet.party;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.banquet.BanquetProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.banquet.CrossPartyMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = CrossProtocol.C_CROSS_LEAVE_PARTY,desc = "")
public class CrossLeavePartyCmd extends CrossCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        long userId = packet.getPlayerId();
        BanquetProto.BanquetLeaveReq req = BanquetProto.BanquetLeaveReq.parseFrom(packet.getBytes());
        String banquetId = req.getBanquetId();
        CrossPartyMgr.leaveParty(banquetId,serverId,userId);
        BanquetProto.BanquetLeaveResp.Builder respMsg = BanquetProto.BanquetLeaveResp.newBuilder();
        respMsg.setRet(0);
        YanQuMessage message = YanQuMessageUtils.buildMessage(Protocol.U_BANQUET_LEAVE, respMsg);
        MessageHelper.sendPacket(serverId, userId, message);
    }

    @Override
    public void sendData() {

    }
}
